package com.example.jikeyoujikeyou.office_sz.view.activity;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.view.PagerAdapter;

import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.WindowManager;
import android.widget.BaseExpandableListAdapter;
import android.widget.ExpandableListAdapter;
import android.widget.ExpandableListView;
import android.widget.ExpandableListView.OnChildClickListener;
import android.widget.ImageView;
import android.widget.Toast;

import com.example.jikeyoujikeyou.office_sz.R;
import com.example.jikeyoujikeyou.office_sz.view.activity.BaseActivity;

public class qqmain extends BaseActivity {



	ViewPager view;
	ImageView im1, im2, im3, im4;

	/*
	ImageView tab1, tab2, tab3, tab_1, tab_2, tab_3;
	ExpandableListView expandableListView;
	ExpandableListAdapter mansadapter;
	String[] group0 = new String[] { "���ߺ���", "��ѧͬѧ", "����ͬѧ" };
	String[] group1 = new String[] { "����Ⱥ", "����Ⱥ" };
	String[] group2 = new String[] { "����������", "����������" };
	String[][] group = { group0, group1, group2 };

	String[][] buddy0 = new String[][] { { "С��", "С��", "ө���" },
			{ "����", "����", "����", "����" }, { "С�㶹", "С��", "С��", "Сӥ" } };
	String[][] buddy1 = new String[][] { { "�������", "ѧ����", "Զ��Э��" },
			{ "Andoid����", "java����Ⱥ", "IOS����", "PHP����" } };
	String[][] buddy2 = new String[][] { { "ɱ����Ϸ", "����ɱ", "66�ֻ�" },
			{ "�ļ�����", "��˼����", "����Ա����", "����Ա����" } };
	String[][][] buddy = { buddy0, buddy1, buddy2 };
*/

	int index0;

	public void initMans(int index) {
		// TODO Auto-generated method stub
		index0 = index;
		/*
		mansadapter = new mansAdapter(qqmain.this, group[index], buddy[index]);
		expandableListView.setAdapter(mansadapter);
		expandableListView.setOnChildClickListener(new OnChildClickListener() {
			public boolean onChildClick(ExpandableListView arg0, View arg1,
					int arg2, int arg3, long arg4) {
				// TODO Auto-generated method stub
				Toast.makeText(
						qqmain.this,
						group[index0][arg2] + "  :  "+ buddy[index0][arg2][arg3],
						Toast.LENGTH_SHORT)
						.show();

				return false;
			}

		});
		*/

	}

	public class MyOnPageChangeListener implements OnPageChangeListener {

		@Override
		public void onPageScrollStateChanged(int arg0) {
			// TODO Auto-generated method stub

		}

		@Override
		public void onPageScrolled(int arg0, float arg1, int arg2) {
			// TODO Auto-generated method stub

		}

		@Override
		public void onPageSelected(int arg0) {
			// TODO Auto-generated method stub
			/*if(arg0==1){
				tab1 = (ImageView) findViewById(R.id.tab1);
				tab2 = (ImageView) findViewById(R.id.tab2);
				tab3 = (ImageView) findViewById(R.id.tab3);
				tab_1 = (ImageView) findViewById(R.id.top_bar_select1);
				tab_2 = (ImageView) findViewById(R.id.top_bar_select2);
				tab_3 = (ImageView) findViewById(R.id.top_bar_select3);
				expandableListView = (ExpandableListView) findViewById(R.id.expandableListView1);
				initMans(0);
			}
			*/
		}

	}

	public class myli implements View.OnClickListener {

		int i;

		public myli(int a) {
			i = a;
			System.out.println(a);
		}

		@Override
		public void onClick(View arg0) {
			// TODO Auto-generated method stub
			view.setCurrentItem(i);
			System.out.println("onclick");
		}
	}

	/*
	public void onTab(View v) {
		switch (v.getId()) {
		case R.id.tab1:
			tab_3.setVisibility(View.INVISIBLE);
			tab_2.setVisibility(View.INVISIBLE);
			tab_1.setVisibility(View.VISIBLE);
			initMans(0);
			break;
		case R.id.tab2:
			tab_3.setVisibility(View.INVISIBLE);
			tab_2.setVisibility(View.VISIBLE);
			tab_1.setVisibility(View.INVISIBLE);
			initMans(1);
			break;
		case R.id.tab3:
			tab_3.setVisibility(View.VISIBLE);
			tab_2.setVisibility(View.INVISIBLE);
			tab_1.setVisibility(View.INVISIBLE);
			initMans(2);
			break;
		default:
			break;
		}
	}
*/
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		System.out.println("oncreate");

		setContentView(R.layout.zhuye);

		this.getWindow().setFlags(
				WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN,
				WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
		view = (ViewPager) findViewById(R.id.view);
		im1 = (ImageView) findViewById(R.id.imageView1);
		im2 = (ImageView) findViewById(R.id.imageView2);
		im3 = (ImageView) findViewById(R.id.imageView3);
		im4 = (ImageView) findViewById(R.id.imageView4);

		im1.setOnClickListener(new myli(0));
		im2.setOnClickListener(new myli(1));
		im3.setOnClickListener(new myli(2));
		im4.setOnClickListener(new myli(3));

		LayoutInflater mli = LayoutInflater.from(this);
		View v1 = mli.inflate(R.layout.qiliao, null);
		View v2 = mli.inflate(R.layout.tongxunlu, null);
		View v3 = mli.inflate(R.layout.gongzuotai, null);
		View v4 = mli.inflate(R.layout.wode, null);

		final ArrayList<View> views = new ArrayList<View>();
		views.add(v1);
		views.add(v2);
		views.add(v3);
		views.add(v4);

		PagerAdapter page = new PagerAdapter() {

			@Override
			public boolean isViewFromObject(View arg0, Object arg1) {
				// TODO Auto-generated method stub
				System.out.println("isViewFromObject");
				return (arg0 == arg1);
			}

			@Override
			public int getCount() {
				// TODO Auto-generated method stub
				System.out.println("getCount");
				return views.size();
			}

			@Override
			public void destroyItem(View container, int position, Object object) {
				// TODO Auto-generated method stub
				((ViewPager) container).removeView(views.get(position));
				System.out.println("destroyItem");
			}

			@Override
			public Object instantiateItem(View container, int position) {
				// TODO Auto-generated method stub
				((ViewPager) container).addView(views.get(position));
				System.out.println("instantiateItem");
				return views.get(position);
			}

		};

		view.setAdapter(page);
		//view.setOnPageChangeListener(new MyOnPageChangeListener());

	}


	/*
	public void startchat(View v) {
		Intent intent = new Intent(qqmain.this, ChatActivity.class);
		startActivity(intent);
	}
	*/

/*	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}
*/
}
